package com.hfjyz.registration.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.validation.Errors;
import org.springframework.web.servlet.mvc.SimpleFormController;

import com.hfjyz.registration.command.OrderInfoPayResultCommand;
import com.hfjyz.registration.contants.ExamContants;
import com.hfjyz.registration.model.Exam;
import com.hfjyz.registration.service.OrderInfoService;

public class OrderInfoPayResultController extends SimpleFormController {
	private OrderInfoService orderInfoService;


	public OrderInfoService getOrderInfoService() {
		return orderInfoService;
	}


	public void setOrderInfoService(OrderInfoService orderInfoService) {
		this.orderInfoService = orderInfoService;
	}


	@SuppressWarnings("rawtypes")
	@Override
	protected Map referenceData(HttpServletRequest request, Object command,
			Errors errors) throws Exception {
		OrderInfoPayResultCommand cmd = (OrderInfoPayResultCommand) command;
		Exam exam = (Exam) request.getSession().getAttribute(
				ExamContants.SESSION_KEY_EXAM_INFO);
		cmd.setExam(exam);
		String userId = request.getParameter("userId");
		cmd.setUserId(Integer.valueOf(userId));
		Map m = orderInfoService.searchOrderPayResult(cmd, errors);
		cmd.setShowDetail(true);
		request.getSession().setAttribute("photoData" + cmd.getIdCardNo(),
				cmd.getUser().getPhoto());
		return m;
	}
}
